//package com.woniu.mgr.components;
//
//import com.fasterxml.jackson.databind.ObjectMapper;
//import com.woniu.mgr.common.Result;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.io.PrintWriter;
//
//@Component
//@Slf4j
//public class LoginSuccessHandler implements AuthenticationSuccessHandler {
//
//   @Resource
//   private ObjectMapper objectMapper;
//
//    @Override
//    public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
//        Result result = Result.success(200,"登录成功",null);
//        result.setCode(200);
//        result.setMessage("登录成功");
//        String resultJson = objectMapper.writeValueAsString(result);
//
//        httpServletResponse.setCharacterEncoding("utf8");
//        httpServletResponse.setContentType("application/json;charset=utf8");
//
//        PrintWriter writer = httpServletResponse.getWriter();
//        writer.write(resultJson);
//        writer.flush();
//    }
//}
